home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / dev / amos / AMCAFExa.lha / AMCAF_Examples / TdStars3.AMOS / TdStars3.amosSourceCode
Encoding:
AMOS Source Code  |  1996-01-17  |  3.4 KB  |  95 lines

  1. ' ************************************* Commands used: 
  2. ' *                                   * Td Stars Bank      Td Stars Draw 
  3. ' *           Amcaf Examples          * Td Stars Limit     Td Stars Init 
  4. ' *          Td Stars 3 V1.0          * Td Planes          Blitter Clear 
  5. ' *      Written by Chris Hodges      * Td Accelerate Off  Blitter Wait
  6. ' *                                   * Td Gravity         Pal Set 
  7. ' ************************************* Td Move            Pal Set Screen
  8. '
  9. ' Remove the mousepointer from screen. 
  10. Hide 
  11. ' Open a screen with 5 bitplanes.  
  12. Screen Open 0,320,256,32,0
  13. Curs Off : Flash Off : Paper 0 : Cls 0
  14. ' Make it totally black. 
  15. For A=0 To 31 : Colour A,0 : Next 
  16. ' Correct the screen position. 
  17. Screen Display 0,128,40,320,256
  18. ' Reserve the stars like usual. Note for turbo board users:
  19. ' Set the value as high as possible (400+).
  20.  Extension_8_0A7E 9,100
  21. ' Limit the stars to a very small block. 
  22.  Extension_8_0A94 0,254 To 1,255
  23. ' Set the used planes to bitplane no. 0. 
  24.  Extension_8_0BCC 0,0
  25. ' Don't accelerate the stars (try it with 'on', it's marvellous!)
  26.  Extension_8_0BAE 
  27. ' Set the gravity to a rather normal value. Try 0,0 as alternative.
  28.  Extension_8_0B78 0,3
  29. ' Init the stars. In this one pixel. 
  30.  Extension_8_0AD0 
  31. ' Reset the limit to the full screen.
  32.  Extension_8_0A94 0,0 To 319,255
  33. ' Switch to Double buffering 
  34. Double Buffer : Autoback 0
  35. ' Now a very important part of the program: Creating the fade palettes.  
  36. ' This is a very critical point because only one mistake can destroy the 
  37. ' whole effect!
  38. ' First we have to reserve a small array for the five colours. 
  39. Dim CO(4)
  40. ' Fill in the different hues.
  41. CO(0)=$4F4 : CO(1)=$3C3 : CO(2)=$292 : CO(3)=$161 : CO(4)=$30
  42. ' This is the main loop. We need five different palettes.
  43. For A=0 To 4
  44.   ' And every colour must be set seperately. 
  45.   For C=0 To 31
  46.     ' Init some values.
  47.     AA=A : CO=0
  48.     ' Check if the current colour must be displayed in front of all other
  49.     ' bitplanes or only before four etc. 
  50.     For AAA=0 To 4
  51.       Add AA,1,0 To 4
  52.       ' This sets the colour. Try following alternatives:  
  53.       If( Extension_8_04F8(AA) and C)>0 Then CO=CO(4-AAA)
  54. '      If(Binexp(AA) and C)>0 Then CO=CO(AAA) : Exit 
  55. '      If(Binexp(AA) and C)>0 Then CO=CO(4-AAA) : Exit 
  56. '      If(Binexp(AA) and C)>0 Then CO=Mix Colour(CO,CO(4-AAA),0 To $FFF) 
  57.     Next 
  58.     ' Copy the colour to the palette buffer. 
  59.      Extension_8_14C6 A,C,CO
  60.   Next 
  61. Next 
  62. Wait Vbl 
  63. ' T is used for timing the next 'explosion point' and BP is a bitplane 
  64. ' counter. 
  65. T=0 : BP=0
  66. Repeat 
  67.   ' Clear the whole plane using the blitter because it's impossible
  68.   ' to kill the 8 times older stars than they normally would be. 
  69.    Extension_8_121C 0,BP
  70.   ' Set the explosion point to a new origin. 
  71.   If(T and 15)=0
  72.     XM=Rnd(319) : YM=Rnd(128)
  73.      Extension_8_0AB8 XM,YM
  74.   End If 
  75.   ' And increase the timer.
  76.   Inc T
  77.   ' Move the Stars one step. 
  78.    Extension_8_0B48 
  79.   ' This is the main trick: Draw the stars on another bitplane each time.
  80.    Extension_8_0BCC BP,BP
  81.   ' Wait for blitter finished. 
  82.    Extension_8_1258 
  83.   ' And draw the new stars.
  84.    Extension_8_0B64 
  85.   ' Chance the palette for this bitplane state.
  86.    Extension_8_149E BP,0 : View 
  87.   ' Increase the bitplane pointer very second only because we are in 
  88.   ' double buffer mode.
  89.   If T and 1 Then Add BP,1,0 To 4
  90.   ' Swap the screens et voila! 
  91.   Screen Swap 
  92.   Wait Vbl 
  93. Until Inkey$=Chr$(27) or Mouse Key<>0
  94. Screen Close 0
  95. End